#include"IdleThreadContainer.h"
#include"MyThread.h"
#include<iostream>

using namespace std;
IdleThreadContainer::IdleThreadContainer() {}

IdleThreadContainer::~IdleThreadContainer()
{
	int i = 0;
	for (Iterator it = idle_thread_container.begin(); it != idle_thread_container.end(); it++)
	{
		cout << i++ << endl;
		delete *it;
	}
}

std::vector<MyThread*>::size_type IdleThreadContainer::size()
{
	return idle_thread_container.size();
}

void IdleThreadContainer::push(MyThread *m)
{
	idle_thread_container.push_back(m);
}
void IdleThreadContainer::pop()
{
	idle_thread_container.pop_back();
}
void IdleThreadContainer::erase(MyThread *m)
{
	idle_thread_container.erase(find(idle_thread_container.begin(), idle_thread_container.end(), m));
}
void IdleThreadContainer::assign(int number, MyThreadPool *m)
{
	for(int i = 0; i < number; i++)
	{
		MyThread *p = new MyThread(m);
		idle_thread_container.push_back(p);
	}
}
MyThread* IdleThreadContainer::top()
{
	return idle_thread_container.back();
}